/*     */ package net.gxf.java2dgame.tetris;
/*     */ 
/*     */ import java.util.Random;
/*     */ 
/*     */ public class Shape
/*     */ {
/*     */   private Utils.ShapeType pieceShape;
/*     */   private int[][] coords;
/*     */ 
/*     */   public Shape()
/*     */   {
/*  15 */     this.coords = new int[4][2];
/*  16 */     setShape(Utils.ShapeType.NoShape);
/*     */   }
/*     */ 
/*     */   public void setShape(Utils.ShapeType shape) {
/*  20 */     for (int i = 0; i < 4; i++) {
/*  21 */       for (int j = 0; j < 2; j++) {
/*  22 */         this.coords[i][j] = Utils.coordsTable[shape.ordinal()][i][j];
/*     */       }
/*     */     }
/*  25 */     this.pieceShape = shape;
/*     */   }
/*     */ 
/*     */   private void setX(int index, int x)
/*     */   {
/*  30 */     this.coords[index][0] = x;
/*     */   }
/*     */ 
/*     */   private void setY(int index, int y) {
/*  34 */     this.coords[index][1] = y;
/*     */   }
/*     */ 
/*     */   public int x(int index)
/*     */   {
/*  44 */     return this.coords[index][0];
/*     */   }
/*     */ 
/*     */   public int y(int index)
/*     */   {
/*  54 */     return this.coords[index][1];
/*     */   }
/*     */ 
/*     */   public Utils.ShapeType getShape() {
/*  58 */     return this.pieceShape;
/*     */   }
/*     */ 
/*     */   public void setRandomShape() {
/*  62 */     Random r = new Random();
/*  63 */     int x = Math.abs(r.nextInt()) % 7 + 1;
/*  64 */     Utils.ShapeType[] values = Utils.ShapeType.values();
/*  65 */     setShape(values[x]);
/*     */   }
/*     */ 
/*     */   public int minX() {
/*  69 */     int m = this.coords[0][0];
/*  70 */     for (int i = 0; i < 4; i++) {
/*  71 */       m = Math.min(m, this.coords[i][0]);
/*     */     }
/*  73 */     return m;
/*     */   }
/*     */ 
/*     */   public int minY()
/*     */   {
/*  83 */     int m = this.coords[0][1];
/*  84 */     for (int i = 0; i < 4; i++) {
/*  85 */       m = Math.min(m, this.coords[i][1]);
/*     */     }
/*  87 */     return m;
/*     */   }
/*     */ 
/*     */   public Shape rotateLeft() {
/*  91 */     if (this.pieceShape == Utils.ShapeType.SquareShape) {
/*  92 */       return this;
/*     */     }
/*  94 */     Shape result = new Shape();
/*  95 */     result.pieceShape = this.pieceShape;
/*     */ 
/*  97 */     for (int i = 0; i < 4; i++) {
/*  98 */       result.setX(i, y(i));
/*  99 */       result.setY(i, -x(i));
/*     */     }
/* 101 */     return result;
/*     */   }
/*     */ 
/*     */   public Shape rotateRight() {
/* 105 */     if (this.pieceShape == Utils.ShapeType.SquareShape) {
/* 106 */       return this;
/*     */     }
/* 108 */     Shape result = new Shape();
/* 109 */     result.pieceShape = this.pieceShape;
/*     */ 
/* 111 */     for (int i = 0; i < 4; i++) {
/* 112 */       result.setX(i, -y(i));
/* 113 */       result.setY(i, x(i));
/*     */     }
/* 115 */     return result;
/*     */   }
/*     */ }

/* Location:           C:\DBDownload\lwjglDemo2\lwjglDemo2\Run.jar
 * Qualified Name:     com.java2dgame.tetris.Shape
 * JD-Core Version:    0.6.2
 */